import * as request from "@/utils/request"

const apiPrefix = "/api/question"

/**
 * 分页查询题目（管理员）
 */
export function listQuestionByPage(params: QuestionQueryRequest) {
  return request.post<PageQuestion>({
    url: apiPrefix + "/list/page",
    data: params
  })
}

/**
 * 删除题目
 */
export function deleteQuestion(params: DeleteRequest) {
  return request.post<boolean>({
    url: apiPrefix + "/delete",
    data: params
  })
}

/**
 * 添加题目
 */
export function addQuestion(params: QuestionAddRequest) {
  return request.post<number>({
    url: apiPrefix + "/add",
    data: params
  })
}

/**
 * 更新题目
 */
export function updateQuestion(params: QuestionUpdateRequest) {
  return request.post<boolean>({
    url: apiPrefix + "/update",
    data: params
  })
}

/**
 * 分页查询题目（用户）
 */
export function listQuestionVOByPage(params: QuestionQueryRequest) {
  return request.post<PageQuestionVO>({
    url: apiPrefix + "/list/page/vo",
    data: params
  })
}

/**
 * 获取题目详情
 */
export function getQuestionVOById(params: { id: number }) {
  return request.get<QuestionVO>({
    url: apiPrefix + "/get/vo",
    params
  })
}

/**
 * 分页查询题目（ES）
 * @param params
 * @returns
 */
export function searchQuestionVOByPage(params: QuestionQueryRequest) {
  return request.get<PageQuestionVO>({
    url: apiPrefix + "/search/page/vo",
    params
  })
}

/**
 * 批量删除题目
 * @param questionIdList
 * @returns
 */
export function batchDeleteQuestions(questionIdList: number[]) {
  return request.post<boolean>({
    url: apiPrefix + "/delete/batch",
    params: {
      questionIdList
    }
  })
}
